package cn.cvs.service.impl;

import cn.cvs.dao.HistoryMapper;
import cn.cvs.pojo.History;
import cn.cvs.service.HistoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("historyService")
public class HistoryServiceImpl implements HistoryService {
    @Resource
    private HistoryMapper historyMapper;
    @Override
    public List<History> getHistoryList(String hPhone,String hFirstDate) {

        return historyMapper.getHistoryList(hPhone,hFirstDate);
    }

    @Override
    public int addHistory(History history) {
        return historyMapper.addHistory(history);
    }

    @Override
    public int deleteHistory(Integer hId) {
        return historyMapper.deleteHistory(hId);
    }

    @Override
    public History getHistoryByHId(Integer hId) {
        return historyMapper.getHistoryByHId(hId);
    }

    @Override
    public int updateHistory(Integer hId) {
        return historyMapper.updateHistory(hId);
    }

    public static void main(String[] args) {
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext-mybatis.xml");
        HistoryService historyService = context.getBean("historyService", HistoryService.class);
        List<History> historyList = historyService.getHistoryList("", "");
        for (History history : historyList) {
            System.out.println(history.toString());
        }
    }
}
